Skip to content

feat(ops): add B02 TSELS and TPRELU support - #2182

Merged
lyfne123 merged 3 commits into
hw-native-sys:mainfrom
hashiqiqixian:feat/ptoas-b02-selection-prelu
Aug 4, 2026
Merged

feat(ops): add B02 TSELS and TPRELU support#2182
lyfne123 merged 3 commits into
hw-native-sys:mainfrom
hashiqiqixian:feat/ptoas-b02-selection-prelu

Conversation

@hashiqiqixian

@hashiqiqixian hashiqiqixian commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace the obsolete three-operand tile.sels path with the canonical mask, src, tmp, scalar TSELS contract
  • add canonical three-input tile.prelu(src, slope, tmp) inference, backend emission, alias rules, debug codegen, and bilingual documentation
  • add focused IR/codegen/memory-reuse coverage plus same-name TSELS/TPRELU hardware tests
  • document the target split and validate the current A2/A3 integer and floating-point TSELS paths against the pinned PTOAS toolchain

Validation

  • exact final revision on 686: 78c36afd0b9260b86313f4ba514462985c140964
  • remote serial C++ build: cmake --build build --parallel 1 passed
  • focused codegen/IR/memory-reuse/debug tests after the final main rebase: 58 passed
  • focused tests cover TPRELU/TSELS inference, valid shapes, codegen, debug emission, memory-reuse alias rules, print/parse round trips, invalid dtype/rank contracts, packed-mask carrier-width boundaries, and A2/A3 scratch valid-column rejection
  • A2/A3 direct hardware before the final main-only rebase: 39/39 passed (TPRELU 10, TSELS 29) with PTOAS v0.53
  • GitHub CI run 30808192525 and Docs run 30808192491: all required checks passed

Platform status

  • A2/A3 hardware: verified
  • A5 simulation: covered by CI
  • A5 physical hardware: pending

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7bb8c956-4266-4ed8-99f7-53a98645e4ae

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR replaces tile.sels with a mask/source/scratch/scalar interface, adds dedicated tile.prelu validation and alias constraints, updates backend emission, and adds hardware, unit, codegen, memory-reuse, and documentation coverage.

Changes

Selection and PReLU operation updates

Layer / File(s) Summary
Operation contracts and Python APIs
python/pypto/ir/..., python/pypto/language/..., src/ir/op/tile_ops/elementwise.cpp
tile.sels now selects between src and scalar using mask and tmp; tile.prelu validates source, slope, scratch, valid-shape, and aliasing contracts.
Backend registration and debug emission
src/backend/common/..., python/pypto/debug/...
Backend arities and row-major registration are updated, and Torch emission uses the scalar false branch for tile.sels.
Hardware operation coverage
tests/st/runtime/ops/*
Runtime tests cover TSELS comparison modes, dtypes, tails, and TPRELU dtypes, tails, and scratch configurations.
IR, codegen, and aliasing validation
tests/ut/codegen/..., tests/ut/debug/..., tests/ut/ir/...
Tests validate operand contracts, output types and valid shapes, emitted operand counts, debug expressions, and forbidden output aliases.
Documentation and status references
docs/en/..., docs/zh-cn/...
Operation references, MemoryReuse no-alias tables, test lists, and PTOAS status rows describe the updated behavior.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant TileSelsWrapper
  participant IR
  participant PTOCodegen
  Caller->>TileSelsWrapper: call sels(mask, src, tmp, scalar)
  TileSelsWrapper->>IR: create tile.sels operation
  IR->>PTOCodegen: emit four-operand tsels
  PTOCodegen-->>Caller: generated operation
Loading

Possibly related PRs

Suggested labels: enhancement

Poem

I’m a rabbit with tiles in my paws,
Masked choices now follow new laws.
Scratch buffers stay neatly apart,
PReLU tests hop through each chart.
Four inputs march, three inputs play—
Docs and code bloom bright today!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 41.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the primary change by identifying the addition of B02 TSELS and TPRELU support.
Description check ✅ Passed The description directly explains the TSELS and TPRELU changes, test coverage, documentation, and validation results.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a4d7e26ec8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/ir/op/tile_ops/elementwise.cpp

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
python/pypto/ir/utils.py (1)

331-345: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Silent float→int truncation when retype_constants=True on an integer operand.

With retyping enabled, a float literal paired with an integer tile no longer takes the float fallback, so _const_at_dtype runs int(value): sels(mask, int32_tile, tmp, -1.5) silently becomes -1. Previously this combination surfaced as a dtype mismatch. Consider rejecting non-integral floats on integer targets instead of truncating.

🛡️ Proposed guard
     if target.is_float() or target.is_int():
+        if target.is_int() and isinstance(value, float) and not float(value).is_integer():
+            raise ValueError(
+                f"Scalar {value} cannot be represented exactly in {target}; "
+                "use an integer literal or cast the operand."
+            )
         return _const_at_dtype(value, target, span)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/pypto/ir/utils.py` around lines 331 - 345, Update the constant-typing
logic before _const_at_dtype so retype_constants=True does not convert a
non-integral float to an integer target. Reject or preserve the existing
dtype-mismatch behavior for float values with fractional parts when
target.is_int(), while allowing integral floats and leaving other promotion
paths unchanged.
🧹 Nitpick comments (1)
src/ir/op/tile_ops/elementwise.cpp (1)

918-932: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Rows check uses physical extent while cols check uses valid extent.

required_rows is compared against tmp_type->shape_[0] but required_cols against tmp_valid_shape[1]. If that mixed contract is deliberate, a one-line comment would help; otherwise both should read from the same extent source. The literal 8 also duplicates the packed-predicate bits-per-byte constant used in MakePackedPredicateTileType; hoisting it to a file-scope constexpr would keep the two paths in sync.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/ir/op/tile_ops/elementwise.cpp` around lines 918 - 932, The UINT8
validation in the surrounding elementwise operator uses inconsistent physical
versus valid extents and duplicates the packed-predicate bit-width literal.
Align the row and column checks to the intended extent contract, document the
choice if the difference is deliberate, and replace the literal 8 in
required_cols and MakePackedPredicateTileType with one shared file-scope
constexpr.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@python/pypto/ir/utils.py`:
- Around line 331-345: Update the constant-typing logic before _const_at_dtype
so retype_constants=True does not convert a non-integral float to an integer
target. Reject or preserve the existing dtype-mismatch behavior for float values
with fractional parts when target.is_int(), while allowing integral floats and
leaving other promotion paths unchanged.

---

Nitpick comments:
In `@src/ir/op/tile_ops/elementwise.cpp`:
- Around line 918-932: The UINT8 validation in the surrounding elementwise
operator uses inconsistent physical versus valid extents and duplicates the
packed-predicate bit-width literal. Align the row and column checks to the
intended extent contract, document the choice if the difference is deliberate,
and replace the literal 8 in required_cols and MakePackedPredicateTileType with
one shared file-scope constexpr.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 303255eb-bb59-47b7-830d-e72a1c4180c9

📥 Commits

Reviewing files that changed from the base of the PR and between 478ddad and a4d7e26.

📒 Files selected for processing (19)
  • docs/en/dev/passes/31-memory_reuse.md
  • docs/en/dev/ptoas-op-status.md
  • docs/en/user/02-operation_reference.md
  • docs/zh-cn/dev/passes/31-memory_reuse.md
  • docs/zh-cn/dev/ptoas-op-status.md
  • docs/zh-cn/user/02-operation_reference.md
  • python/pypto/debug/torch_codegen.py
  • python/pypto/ir/op/tile_ops.py
  • python/pypto/ir/utils.py
  • python/pypto/language/op/tile_ops.py
  • src/backend/common/pto_ops_elementwise.cpp
  • src/ir/op/tile_ops/elementwise.cpp
  • tests/st/runtime/ops/test_activation_ops.py
  • tests/st/runtime/ops/test_prelu.py
  • tests/st/runtime/ops/test_sels.py
  • tests/ut/codegen/test_pto_codegen_ops.py
  • tests/ut/debug/test_torch_codegen.py
  • tests/ut/ir/operators/test_tile_ops.py
  • tests/ut/ir/transforms/test_memory_reuse.py

@hashiqiqixian

Copy link
Copy Markdown
Contributor Author

Review follow-up: 9dceb8d also rejects non-integral floating constants before integer retyping. The PReLU scratch check intentionally uses physical rows (the extra hardware scratch row) and valid columns (usable packed-predicate bytes); the shared 8-bit packing constant and an explanatory comment now make that distinction explicit.

@hashiqiqixian
hashiqiqixian force-pushed the feat/ptoas-b02-selection-prelu branch 3 times, most recently from 4489944 to b21d263 Compare July 29, 2026 17:51
@Little-oil

Little-oil commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Important

再次更新:最新评论 4849843411 的第 1 项 blocker 与 v0.55 强制刷新要求不正确,已在更正 review中撤回。 请以该更正为准;下面旧 head b21d263d 的历史问题仍仅作记录。


#2166 复核当前 head b21d263d 后,B02 的 A2/A3 状态暂时还不能保持 。当前有两个 blocker:

  1. 当前 required system-tests-direct 实际失败 11 项

    • signed INT8 TPRELU tmp 被固定 PTO-ISA 的 uint8_t static assertion 拒绝;
    • UINT16/UINT32 TSELS 生成 ui16/ui32TCMPS mask,PTOAS 不接受;
    • INT32 TSELS 真机有 540/1024 个元素不匹配;
    • mask-carrier / arbitrary-tmp case 的 1/4-byte row 未满足 32-byte 对齐。
  2. DeduceTilePreluType 仍允许任意非 8-bit tmp。该 placeholder 语义只适用于 A5;A2/A3 要求 UINT8 scratch。现在无效输入会通过 IR,直到 PTOAS/C++ 编译才失败。请增加 target-aware codegen guard 和对应负向 UT。

请先修复这 11 个当前矩阵中的失败,并在仓库固定的 PTOAS v0.48 / PTO-ISA 上重跑真机矩阵;通过后再恢复

@hashiqiqixian
hashiqiqixian force-pushed the feat/ptoas-b02-selection-prelu branch 4 times, most recently from b4079f0 to 7956b51 Compare July 30, 2026 04:40
@hashiqiqixian

Copy link
Copy Markdown
Contributor Author

已按该反馈复核并修复,当前 head 为 7956b51b

  • B02 的 A2/A3/A5 dtype、mask carrier、tmp/alignment 与 valid_shape 场景均保留在 ST;
  • 无符号 TSELS 的 scalar 现按 PTOAS 的 signless integer 约束生成同位宽 i8/i16/i32,高位常量按二补码保持 bit pattern,并补充了 IR/codegen 回归测试;
  • A2/A3 的 TPRELU tmp 约束及负向 UT 已覆盖。

最新 CI 中 system-tests-directsystem-tests-a5sim、普通/分布式 system tests、UT、codegen、pre-commit、clang-tidy 均已通过。

@Little-oil Little-oil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论:当前 head 7956b51b 暂不建议合入,下面 3 项需要先修复。

先校正旧结论:本次按仓库当前固定的 PTOAS v0.54(runtime/PTO-ISA 仍为 83d01313)复核。最新 A2/A3 真机任务 已全绿,B02 的 TPRELU 10 项、TSELS 27 项均通过。因此我之前基于旧 head b21d263d 提到的 11 项失败,以及旧 review 中“A2/A3 不支持整数 TSELS”的判断,都已过时;当前 INT16/UINT16/INT32/UINT32 路径有真机证据。

  1. [blocker] tile.sels 没有验证 packed mask 是否足够覆盖 src.valid_shape

    DeduceTileSelsType 目前只检查 mask 的 rank/dtype。例如 mask=[1,32] ui8src.valid_shape=[16,512] 会通过 PyPTO/PTOAS verifier,但固定 PTO-ISA 会按 dst 的 16 个 valid rows 逐行读取 mask,而每行还需要覆盖 512 个 packed predicate bits;这会读出 mask 的实际存储范围,得到错误 predicate,甚至越界。请按 carrier 字节宽度验证 mask 的行覆盖和每行 packed-byte 容量(动态关系也应可证明),并补“过小 mask”负向 UT 与宽列边界 ST。

  2. [blocker] TPRELU 的 alias/tmp 规则没有按 target 建模,当前同时有误拒和漏检。

    args[0] != args[1] 无条件拒绝相同 src/slope,后面的 8-bit tmp extent 检查及 .not_inplace_safe() 也全局套用。PTOAS v0.54 的 A5 实现不使用 tmp,并明确允许 tmp == dst;A5 也没有 src/slope 不重叠限制,所以这些规则会拒绝合法 A5 形式。反过来,A3 要求 src/slope/tmp/dst 的存储范围两两不重叠,但同一 base 上两个重叠 tile.slice 是不同 Expr,会漏过当前判断。请在 target 和 MemRef 已知的阶段按 base+range 校验 A3,并补 A5 same-input/tmp-placeholder 正向用例、A3 overlapping-view 负向用例。

  3. [G2] codegen UT 还不是 #2166 要求的 exact codegen 断言。

    当前 TSELS/TPRELU 测试 只统计 ins 数量并检查类型字符串;mask/src/tmp/scalar 换序或 outs 错误时仍可能通过。请断言完整的 SSA operand 顺序和 outs,覆盖两个 target 分支。

另外请同步更新 PR 描述:其中仍写 PTOAS 0.48、A2/A3 仅 FP16/FP32、19 passed/22 deselected;当前事实是 PTOAS v0.54、A2/A3 还支持已真机通过的 16/32-bit integer TSELS,B02 当前为 37 项真机用例通过,A5 真机仍 pending。

@hashiqiqixian
hashiqiqixian force-pushed the feat/ptoas-b02-selection-prelu branch 6 times, most recently from 13c1917 to 25daa7e Compare July 31, 2026 06:59

@Little-oil Little-oil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论:当前 head 25daa7e6 暂不建议合入。按 PTOAS v0.54(tag 195fdb8c)和 #2166 的 B02 / G0–G5 复核后,仍有 3 个 blocker。

先同步已完成项:我在上次 review 提到的 packed-mask 覆盖、TPRELU target-aware alias/tmp、exact SSA operand/outs 三项,在当前 head 都已实质修复;A2/A3 当前真机任务也全绿。下面只列当前仍存在的问题。

  1. [blocker / G2] A5 TPRELU 发出了 PTOAS v0.54 不存在的两输入形式。

    A5 codegen 只发 src, slopelayout 注册 也只处理两个输入。但 PTOAS v0.54 的 canonical ABI 在所有 target 上都固定为:

    pto.tprelu ins(%src0, %src1, %tmp : ...) outs(%dst : ...)

    A5 “不使用 tmp”只表示实现不读写它,不表示可以从 IR 签名删除;tmp 仍须是 Vec/row-major,但允许 tmp == dst。我用仓库当前 pin 的 ptoas 0.54 实跑最小 IR:

    • 三输入且 tmp == dst:exit 0;
    • 删除第三个输入:exit 1,error: expected ','

    当前 exact codegen UT 反而把错误的两输入形式写成了期望值。请让 A5 也发三个输入、给 tmp 设置 row-major,并保留现有 A5 tmp/result 可复用规则;中英文文档里的 “A5 omits tmp” 也需改成 “保留 operand,但实现不使用”。

  2. [blocker / G1] A2/A3 TSELS 没有禁止 tmpmask/src 的存储区间重叠,会静默算错。

    DeduceTileSelsType 只检查 tmp 的 rank;.forbid_output_alias(0/2) 只约束 dst,不约束输入之间。因此下面两种调用都会通过并生成 PTO:

    pl.tile.sels(mask, src, src, scalar)   # tmp == src
    pl.tile.sels(mask, src, mask, scalar)  # tmp == mask

    固定 A2/A3 PTO-ISA 会先执行 *scalarPtr = scalar,之后才读取 mask/srcvsel:前者会污染 src[0,0],后者会污染 mask 开头。请在 A2/A3 backend、MemRef 已知后,按 base+range 禁止 tmpmask/src overlap,并补同一变量及 overlapping slice 的负向 UT。A5 不读取 tmp,应继续允许这些 alias。

  3. [blocker / G1] A2/A3 TPRELU 把动态 scratch 容量关系的 kUnknown 当成合法。

    rows/cols 两项检查 都使用 proof != kFalse,所以“无法证明安全”的动态关系会被放行。例如:

    • src/slope shape=[16,256],共同 runtime valid_shape=[M,N]
    • tmp shape=[2,32]valid_shape=[1,1]

    编译时 M + 1 <= 2ceil(N / 8) <= 1 都是 kUnknown,当前代码仍会 emit;运行 M=16, N=256 时则同时违反两项 scratch 契约。固定 ISA 会按 dst.validRow 在 tmp 上创建 额外 scratch row 的 TSUBVIEW,此时可能越界或产生错误 predicate。请要求关系可证明安全,或使用 physical 上界/runtime guard,并补动态负向 UT;不能只排除 kFalse

  4. [should-fix / G1–G2] TSELS 的 packed-capacity UT 把 PTOAS 无法组装的物理行宽当成正例。

    当前 UT 接受 i16[2,17](每行 34B)和 i32[2,9](每行 36B)。我用 v0.54 实跑对应 pto.alloc_tile,会直接报:

    expects result row-major none_box tile row byte size ... to be 32-byte aligned
    

    这项宜在实际 layout/MemRef 已知后按 physical stride 校验,避免简单按逻辑 cols 检查而误拒有对齐 backing stride 的 subview。至少不要把 34B/36B 形式作为“可执行正例”;可改为对齐 physical shape + 较小 valid shape,并增加 pinned PTOAS assembly 断言。

  5. [G3 / G5] 请校正 A5 覆盖声明和当前计数。

    system-tests-a5sim 没有运行 test_prelu.pytest_sels.py,这也是上述 A5 ABI 错误在 required CI 全绿时未被发现的原因。因此 PR 描述中的 “A5 simulation: covered by CI” 目前不成立:请把两份 ST 真正接入 A5sim,或明确标为 pending。另一个小的状态更新是,当前 A2/A3 direct job 实际为 TPRELU 10 + TSELS 29 = 39 项通过,不是正文中的 37 项。

修复后建议至少补三条验收证据:A5 三输入 pto.tprelu 通过 v0.54 组装;A2/A3 TSELS overlap 被 PyPTO 提前拒绝;动态 TPRELU 小 scratch 不再以 kUnknown 放行。

@hashiqiqixian
hashiqiqixian force-pushed the feat/ptoas-b02-selection-prelu branch 7 times, most recently from b8cf966 to 78c36af Compare August 3, 2026 11:06

@Little-oil Little-oil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论:当前 head 78c36afd 暂不建议合入。按 PTOAS v0.55#2166 的 B02 / G0–G5 重新复核后,上次 review 的 3 个 blocker(A5 TPRELU 三输入 ABI、A2/A3 TSELS 的 tmp-mask/tmp-src overlap、动态 TPRELU scratch 的 kUnknown)以及未对齐 packed-capacity 正例都已经修复。当前还剩下面 3 项。

  1. [blocker / G1] A2/A3 TSELS 误拒了合法的 tmp == dst

    当前 backend 检查dst 也放进 tmp 的禁止重叠集合,memory reuse 也禁止 output 复用 arg 2。但 PTOAS v0.55 官方 TSELS sample 明确调用 TSelSOp(tb0, tb1, tb2, c64, tb2),即 tmpdst 是同一 tile;我用 ptoas 0.55 对该形式在 a2a3 都实跑组装成功。

    这也符合固定 PTO-ISA 的执行顺序:先把 scalar 写进 tmp、set_cmpmask 并做 barrier,之后才循环写 dst。因此应继续禁止 tmpmask/src overlap,但允许 tmp == dst;同时删除 memory-reuse 的 arg 2 禁止项,并更新文档/UT,补一个官方同形的 A2/A3 正向 assembly case。

  2. [G3 / G5] A5sim job 实际执行了 0 个 TPRELU/TSELS case,PR 正文的覆盖声明不成立。

    Workflow 的确把两个文件写进了命令,但测试全部参数化 ONBOARD_PLATFORMS(只有 a2a3/a5),而 job 传入 --platform=a5sim当前 green job 因此是 217 collected / 188 deselected / 29 selected,执行列表里没有任何 test_prelu.py::test_sels.py::

    请二选一:把相应参数扩展到 a5sim 并确认日志出现实际 B02 node id;或者把 A5 simulation 明确标为 pending,不再把这个 green job 当作 B02 的 A5 证据。

  3. [G2 / test] 删除 [1,1] UINT8 这个 A5 正向测试输入。

    test_tprelu_undersized_tmp_is_a3_only_validation 在 A5 分支把 [1,1] UINT8 当作可生成正例,但 PTOAS v0.55 会在 pto.alloc_tile 阶段直接拒绝:row byte size ... must be 32-byte aligned, but got 1 bytes,尚未进入 TPRELU verifier。按当前工具链约束,先不要把这种形态作为测试用例;请删除它,或改成行宽对齐的占位 tile(例如 [1,32] UINT8)并让生成结果实际通过 v0.55 组装。

版本说明:PR/required CI 目前仍固定 PTOAS v0.54,正文还引用 final rebase 前的 v0.53 真机结果;这些都不能作为当前 v0.55 基线的证据。我在 v0.55 下确认 canonical 三输入 TPRELU、对齐的 A5 [1,32] UINT8 placeholder,以及 A2/A3 TSELS tmp == dst 都可组装。修复后请用 v0.55 对最终 head 刷新版本和验证记录。

@hashiqiqixian
hashiqiqixian force-pushed the feat/ptoas-b02-selection-prelu branch from 78c36af to 3d7f0fa Compare August 4, 2026 02:49

@Little-oil Little-oil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

更正:撤回我在上一条 review中的第 1 项 blocker 和 v0.55 强制刷新要求。 请不要继续把这两项当作 #2166 的合入门槛。

  1. A2/A3 TSELS tmp == dst 不应被我定为 G1 blocker。

    我只依据 PTOAS sample、assembler 接受和固定 ISA 的指令顺序,就断言 PyPTO “必须”允许该 alias;这个推论越过了证据边界。sample 使用同一个 tile SSA 且只做构造/verify,assembler 成功也只说明 verifier 没拦。PTOAS v0.54/v0.55 的 TSelSOp::getEffects 在 A2/A3 上把 tmpdst 都建模为 write,memory planner 还会为 scratch/output 建立 forbid-alias conflict#2166 B02 也没有要求 TSELS 接受这个自动复用。

    因此,旧的保守 no-alias 保护是可接受的,不是 correctness blocker。当前 head 已按我的错误反馈放开自动复用;最小纠正是恢复旧保护。如果选择保留这项优化,则需要补一条明确迫使 tmp/result 同地址的 A2/A3 真机数值 ST,并说明它与 PTOAS planner 保守规则的关系;但这项优化不是完成 B02 的前置要求。

  2. A5sim 的事实成立,但严重性应降级。

    当前 A5sim job 确实执行了 0 个 TPRELU/TSELS case,PR 正文 “A5 simulation: covered by CI” 应修正;但 #2166 G3 只要求至少一个支持平台完成真机 ST,已有 A2/A3 真机证据可以满足,A5 保持 pending 即可。这不是否定 A2/A3 的 blocker。

  3. [1,1] UINT8 测试问题仍然成立,而且应统一清理。

    PTOAS v0.54/v0.55 都会在 pto.alloc_tile 阶段因 1-byte row 不满足 32-byte alignment 而拒绝。当前有三处这种测试输入:TSELS codegenTPRELU A5 正向 codegenTPRELU IR。请删除不需要的 case,或统一换成当前 A5 EmitC 路径可组装、且仍能表达“小 placeholder”的 [1,32] UINT8。其中 A5 正向 codegen case 是直接的 G2 must-fix。

  4. 仓库 pin v0.54 才是本 PR 的验收版本。

    PR/base 当前仍 pin PTOAS v0.54#2166 的 G0/G2 要求按 pinned 版本验收,并要求工具链升级单独提交。v0.55 只应作为额外的前向兼容检查,不能要求 #2182 顺带刷新 pin/CI。

修正后的结论: 原 review 中唯一直接成立的代码/测试 blocker 是无效的 [1,1] UINT8 A5 正向用例;A5sim 覆盖声明和旧版本验证文字属于状态/文案修正。TSELS tmp/dst 自动复用不应由我的错误 review 强制加入。

@hashiqiqixian
hashiqiqixian force-pushed the feat/ptoas-b02-selection-prelu branch from 3d7f0fa to d216b04 Compare August 4, 2026 03:46
@hashiqiqixian
hashiqiqixian force-pushed the feat/ptoas-b02-selection-prelu branch from d216b04 to d366752 Compare August 4, 2026 04:51
@lyfne123
lyfne123 merged commit a47d300 into hw-native-sys:main Aug 4, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants